package com.exp.bookhouse.pojo;
import com.baomidou.mybatisplus.annotation.*;
import com.exp.bookhouse.swagger.IgnoreSwaggerParameter;
import com.exp.bookhouse.util.AmountUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@ApiModel("书籍实体类Book")
@TableName("tb_book")
public class Book implements Serializable {

    @ApiModelProperty(value = "书籍id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "书名")
    private String name;  //书名

    @ApiModelProperty(value = "作者")
    private String author;  //作者

    @ApiModelProperty(value = "单价，单位：分")
    private Long price; //单价，单位：分

    @ApiModelProperty(value = "单价， 单位：元")
    @TableField(exist = false)
    private String priceStr;  //单价， 单位：元

    @ApiModelProperty(value = "书本描述")
    private String description; //书本描述

    @ApiModelProperty(value = "出版社")
    private String publishHouse;    //出版社

    @ApiModelProperty(value = "大图片地址，轮播图，多个地址之间用逗号隔开")
    private String pic;     //大图片地址，轮播图，多个地址之间用逗号隔开

    @ApiModelProperty(value = "小图片地址")
    private String icon;    //小图片地址

    @ApiModelProperty(value = "库存")
    private Integer stock;  //库存

    @ApiModelProperty(value = "是否推荐 0：否  1：是")
    private Integer recommend;  //是否推荐 0：否 1：是

    @ApiModelProperty(value = "分类id")
    private Long categoryId;    //分类id

    @ApiModelProperty(value = "创建时间",hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;    //创建时间

    @ApiModelProperty(value = "更新时间",hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;    //更新时间

    @ApiModelProperty(value = "轮播图")
    @IgnoreSwaggerParameter     //不递归展开
    @TableField(exist = false)
    private List<String> pics;

    public Book() {
    }

    public List<String> getPics() {
        return pics;
    }

    public void setPics(List<String> pics) {
        this.pics = pics;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        String str = "";
        if(price != null){
            str = AmountUtil.changeF2Y(price);
        }
        this.priceStr = str;
        this.price = price;
    }

    public String getPriceStr() {
        return priceStr;
    }

    public void setPriceStr(String priceStr) {
        this.priceStr = priceStr;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPublishHouse() {
        return publishHouse;
    }

    public void setPublishHouse(String publishHouse) {
        this.publishHouse = publishHouse;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public Integer getRecommend() {
        return recommend;
    }

    public void setRecommend(Integer recommend) {
        this.recommend = recommend;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", priceStr='" + priceStr + '\'' +
                ", description='" + description + '\'' +
                ", publishHouse='" + publishHouse + '\'' +
                ", pic='" + pic + '\'' +
                ", icon='" + icon + '\'' +
                ", stock=" + stock +
                ", recommend=" + recommend +
                ", categoryId=" + categoryId +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
